#define DEBUG
#include <cstdio>

using namespace std;

const long long mods=1000000007;
const int maxk=15, maxn=15;

long long solve(int o, int k, int *c) {
  static int pillar[maxn+2];
  if (o<=0) {
    return 1;
  } else {
    long long ret=0;
    for (int i=1; i<=k; i++) {
      if (c[i] && pillar[o+1]!=i) {
	c[i]--;
	pillar[o] = i;
	ret = (ret+solve(o-1, k, c))%mods;
	c[i]++;
      }
    }
    return ret;
  }
}

int main() {
#ifdef DEBUG
  freopen("2.in", "r", stdin);
  freopen("2.out", "w", stdout);
#endif

  int t;
  scanf("%d", &t);
  for (int ti=1; ti<=t; ti++) {
    static int c[maxk+1];
    int k, n=0;
    scanf("%d", &k);
    for (int i=1; i<=k; i++) {
      scanf("%d", c+i);
      n += c[i];
    }
    printf("%lld\n", solve(n, k, c));
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
